package com.zhongyu.consumer.controller;

import com.zhongyu.comm.vo.DetailVo;
import com.zhongyu.comm.vo.Result;
import com.zhongyu.consumer.service.DetailClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/detail")
public class DetailController {

    @Resource
    private DetailClientService detailClientService;

    @GetMapping("/query")
    public List<DetailVo> query(){
        return detailClientService.searchAll();
    }

    @GetMapping("/del/{id}")
    public Result del(@PathVariable int id){
        try {
            detailClientService.del(id);
            return Result.success("删除新闻成功");
        }catch (Exception e){
            return Result.fail("删除新闻失败");
        }
    }
}
